import hide_loading from '@dfeidao/atom-wxapp/api/interaction/hide-loading';
import show_loading from '@dfeidao/atom-wxapp/api/interaction/show-loading';
import show_toast from '@dfeidao/atom-wxapp/api/interaction/show-toast';
import { IFeidaoAiWeappPage } from '@dfeidao/atom-wxapp/interfaces';
import get_local from '@dfeidao/atom-wxapp/local/get';
import set_local from '@dfeidao/atom-wxapp/local/set';
import nodejs from '@dfeidao/atom-wxapp/msg/nodejs';
import render from '@dfeidao/atom-wxapp/render/render';


export default async function a002(fd: IFeidaoAiWeappPage) {
	const pick_no = get_local(fd, 'pick_no') as string;
	const page_no = get_local<number>(fd, 'page_no');
	try {
		// app-pick_detail-find
		const data = await nodejs<any[]>('ready-det/s001', {
			filter: {
				pick_no
			},
			page_size: 2,
			page_no: page_no + 1// 23
		});
		console.log(data, '------------------');
		if (data.length > 0) {
			const list_data = get_local(fd, 'list_data') as any[];
			render(fd, { data: list_data.concat(data) });
			set_local(fd, 'page_no', page_no + 1);// 23
			set_local(fd, 'list_data', list_data.concat(data));
		} else {
			show_toast('没有更多数据了', 'none');
		}
	} catch (error) {
		show_loading('读取数据失败');
		hide_loading();
	}
}
